<template>
  <div class="content">
    <n-image :width="screenWidth" height="360" :lazy="true" :src="bj" />
    <div class="detbox" style="position: absolute; top: 0; width: 100%">
      <!-- <Header></Header> -->
      <t-navbar title="" :fixed="false" left-arrow @left-click="handleBack">
        <!-- <template #right>
          <t-icon name="share-1" size="20px" />
        </template> -->
      </t-navbar>
      <CartoonDet :getId="getId" ref="detRef"></CartoonDet>
    </div>
  </div>
</template>

<script setup>
import { ref, onBeforeMount, onMounted, onUnmounted } from "vue";
import Header from "@/components/Header.vue";
import CartoonDet from "@/components/cartoonDet.vue";
import { Message } from "tdesign-mobile-vue";
import { useRouter, useRoute } from "vue-router";
import bj from "@/assets/bj2.webp";
import logos from "/src/assets/logo.png";
import logo from "@/assets/logo.png";
import logoText from "/src/assets/logo-text.png";

const router = useRouter();
const route = useRoute();
const getId = ref(0);
const code = ref("");
const isPageLoading = ref(true);
const isCopied = ref(false); // 标记是否已复制（避免重复触发）

const screenWidth = ref(0);

const getIdDate = () => {
  if (route.query.courseId) {
    getId.value = Number(route.query.courseId);
  }
};

// 返回上一页
const handleBack = () => {
  router.back();
};

onBeforeMount(() => {
  getIdDate();
});

onMounted(() => {
  // 监听页面根元素的点击事件（页面任意区域点击）
  screenWidth.value = window.innerWidth;
});
</script>
<style scoped lang="scss">
.content {
  background-color: #fff;
  position: relative;
  padding-top: 10px;
  min-height: 100vh; /* 确保页面高度占满，点击区域完整 */
  width: 100%;
  overflow-x: hidden;
}

// 邀请码显示区域样式
.code-container {
  padding: 15px 20px;
  margin: 15px;
  background: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

  .code-text {
    font-size: 16px;
    color: #333;
    word-break: break-all; // 防止长邀请码溢出
  }

  .copy-tip {
    font-size: 14px;
    color: #4cd964; // 成功色
    margin-left: 10px;
  }
}
.logo-box {
  background-color: #fff;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  height: 50px;
  bottom: 0;
  // left: calc(50% - 100px);
  width: 100%;
}
</style>
